Remove a bunch of unnecessary DB hits from teacherreg.

Thanks @mgersh for pointing out the repeated query.