refactor sessions and registration