Added rudimentary error handling and (thereby) remove warnings