Cleaned code, split files, added logout option