Fixes in error throwing and reporting