Added functionality to write data/call arbitrary functions on fatal errors