Added logout, clean up code