Casting in place, sorting; split var.cpp into varheap.cpp