imported from http://tktable.sourceforge.net