Fixing bugs detecetd by kitware builds