refactor projects_controller and fix some related bugs