Added some KASSERT and debug statements