small fix.
add state feature.
delete debug prints.
bug fix.
more efficient state.