Implemented an global exception handler firing an exception event when an exception occurs.

Also improved some minor things in the code, made some fields readonly and other things.