Fixed a number of edge cases which affected debug mode. Improved notice handling.