Changes for compatibility with java < 1.7