Initial code from https://code.google.com/p/wiki-java/