more exceptions handling and error fixes