Some cleanup, plus getting a start on registration function.