Fixed a few bugs and improved error messages.