[Core] Move message handling out from the core.