Fix exception messages and undefined var name