Added helper functions for constructing and deconstructing messages