Exception handle and other optimization