Added some exceptions handling