Decided to solve this problem in Java instead.