Changes to facilitate calling through py4j