major upgrades and rewrites