Extract spread runtime code into a new file

The intent is to make the runtime library more modular.

See #1007