Added comments, got thread safety working as a prototype for logging in and out