memory usage optimizations for read and write operations

exceeds 90 characters.