Avoid some exceptions in code to make debugging easier
Added some debugging messages