TRUNK-3926 updated messages code to make it more readable