Fixes the multiple prepopulation bug.
Fixes the long delay in photo search.
Cleans up the code a little bit