Not sure, but your gallery sure is behaving weirdly... sometimes it loads object, sometimes not. Very erratic and slow. I'd think about a new host if I were you ;-)
The "Cleaning up" part doesn't do much, just a garbage collection and cache clearing. It shouldn't matter if that part throws an error. I would guess that your server is just very wacky and all kinds of things are wrong that we'll never be able to diagnose.
As long as it's working now, don't worry about it.
If you want to, try clicking "Refresh" under the stats on the admin front page, it might throw the same error. Then we know it's just the garbage collection...