intial source from http://www.sf.net/projects/wdte