clamp logitinv

also added various (toggled-off) debugging statements