Major cleanup for @arlolra's file transfer commit #247