Refactored controllers and added new functionality