changed memory pic; reordered sections; repurposed some code