Fixed some exception handling code
Updated version