First implementation, tested on Mac OS X, with Java 7.