Move most sql into models.py. Move license, profile, and manifest file generation here from epicbot. Minor clean-up.