Working register/login, cleaned up code