cleanup of def. Added constants and fixed Exceptions.