Implemented flush method and tests, made implementations serialisable