[DO NOT MERGE] Initial commit of refactor. Still contains old code.

Looks like the which, shellescape, fork_and_run, read_fork_result, wait_and_report, state_already, and save_and_exit methods is no longer in use