Split __init__ into several modules and remove flask-peewee dependency.

This should make imports more sensible and with less side effects. Also might reduce the memory footprint of the workers.