Move some common functionality into modules.