signin, signout, stats, some refactoring