Refactor fatal error handling

This pull request refactors the fatal error handling away from abusing the output layer and grepping for errors in it. Instead, we use [error_get_last()](http://php.net/error_get_last). This way, call to statements such as `echo`, `var_dump` and so on will directly surface.