HUGE photom-error related rewrite, still some things left to patch