Fork source from jontools.sourceforge.net/saj