Changed new ArrayList<> to appropriate generic version because Java 1.6 does not automatically cast them correctly.