Cleanup and refactoring. Removed unnecessary login/logout code from index controller.

Install template script incoming!