Refactored to use smfCommand.js module to run commands, and smfError.js
module to handle errors. Use closures to save passing so much around in
function calls.