Write the dispatch (and out) functions.