more or less finished porting to c++, serious testing may now commence