Still broken, rewriting in Java anyway.