bug fixed: state classification was wrong.
bug fixed: doubled ranges when state was edited.
cleaner code.
log improved.