Implement login. (fix bugs). Close #1