moved messages functions, some fixes