huge code overhaul