some commenting and tidying of registration process