Made first steps to improve error handling