Moved chat modules to separate file

Also changed a few declarations to public, so that they could be used
from the new module.