Finished port

Ported remaining functions to Java, and probably introduced a few bugs
along the way. But it compiles!