Incorporated MZD feedback on function names and error messages. Added code comments.