fixes. Added debug switch