chat module almost refactored; some small fixes (mostly connected with permissions)