Refactor controllers and views