format messages; fix bugs;