Added debug messages. Fixed typos.