added THROW macro for exceptions, added comments, fixed typo