Debug definition filling

Also fix a variety of bugs