refactor message module, fix bugs and clean up demos