Major code overhaul