attempt to improve exceptions handling. There are still many dangerous things and exceptions should be generaly rethinked