c++: major overhaul of eco.cc (appearently I was an idiot)