Added the ability to load images from the DB. Cleaned up some code