refactor app to use a nicer application factory pattern and blueprints