Version 2

Really Sloppily Done. Just used functions, but definitely feel like
there are too many globals. Will correct in future revisions.