changed error reporting and some file path logic