External commands

This is a large set of changes that replaces a big part of how we handle external commands today. Please see individual commit messages for more information.