Added exceptions handling.