Added some checks for problem situations