bigger cleanup: corrections in state handling, filename conventions etc.