Moving stuff from sylvains code