Trying to get this stupid thing to compile.
Shifting from deferred to when for promises.
Lots of moving over code.