Improved error message.
Formatting
Comments and cleanup