Copy from http://code.google.com/p/ctbparser/