Removed possible null ref in exception handling code