Refactored registration in two states (issue #48)

Partially issue #41