Thanks to Samuel Tardieu <sam@inf.enst.fr> for instigating this update and providing some of the changes.