improved error reporting and squashed a couple bugs