Added debug target for Windows.
Replaced assertion with defensive programming (to prevent underflow).