Refactored to conform to standards. Added error messages.
Refactored to conform to standards. Added error messages.