Implementations for read and write methods. Needs testing.