Cleaned up code using templates, added check login functionality
Merge remote-tracking branch 'download/master'