Fix DTD bug and count instructions