merge and compress metadata message

* merge changes with the previous message.
* compress metadata message.
* some cleanup.