Rewrote program

New structure is more efficient. Also fixed the set working directory
problem so that the original wd is restored prior to completion of
function.
Initial commit
Initial Commit