Slowly porting C++ code to Java...