split messages module into separate file
a few trivial fixes
some more small fixes