refactored back end and photos controller quite a bit, fixed javascript bugs as well, tests should be green here