minor cleanup and basic loader function (incomplete)