Refactoring project controller to allow for testing.