Refactoring: using blueprints, app factory