First shot at Java rewrite