Fixed the previous nasty bug.

Turns out we shouldn't call $apply anywhere we want.