Some utility functions I wrote for Java