Refactor sign in (#19, close #25).