Convert code to Java 7

Related to #1167.