Cleaned up code repetitions of messaging and shared memory read/write.