add message buffer class, refactoring for common read/write interface