Fixed error reporting bugs