add messageManager and fix some problems