working ibmc algorithm; fix unwinding bug

still not correct in all cases
Cleanup