Add logging to FileInputOutput, StateManager. Fix some assertions