Integrated @jdfwarrior's workflow.php, added error checking by @stouty. Fixed a couple bugs.