Fixed the code to validate user creation privileges and cleaned up some code.