Bug fixes register function and added error messages to register