Refactored to include read() and write() gateway functions for visibility exercise.