More assorted improvements. Added error/$error to keep track of process exit code and function status.