Some more code organization and stylistic changes.