added some fixes, code refactoring, changed messaging design