added photo_size into config
a lot of fixes, some optimizations