fixing error reporting etc.