Code cleanup, bug fixes

--restructured code to make it look nicer
--changed relevant fs calls to oldFs
--corrected compilation errors, still not tested actual functionailty