Tumbnail and cleanup.

Added build in tumbnailing and cleaned up code