Move message formatting functions to separate file