Cleaned up buffer code in writeMessage; removed extraneous logger calls.