Added lots more documentation, saving state