Import from http://www.da.isy.liu.se/~ehliar/pyxdl/