Deleted images, refactor all queries to work with postgresql