A clone of the code taken from http://javaanpr.sourceforge.net/