Some more amendments to better error handling