memory usage optimizations for read and write operations

Line length is greater than our hard limit of 85 for function definitions.