Added persistence interface, plus some cleaning up.