Cleaned up script, added comments
Added command-line arg handling, e.g. to specify -fg to run process in foreground (useful for debugging when using pdb)