Fixed several bugs related to image storing; refactored most fields on
the DB package.