Added proper logout, deleted unnecessary code