Further cleanup and error-checking for command-line tool.
Proper splicing for action generation.