Minor bug fix and error reporting