Improved stack trace

I tried to test but set_error_handler() failed and I couldn't test

I might've made the trace come twice.