Copied stuff line by line from book code. Registration works now.