part refactor of io and state
refactored some more, mostly io
corrected usage of python reserved terms, import warnings, more io refactoring