Cleanup thumbnail code

I wish the code from android.com worked