big code cleanup

cleaned up autorun function
improved page render flow
improved use of cookie
removecookie on logout added
deleted unnecessary files and moved third party scripts to lib folder