merged Quentin Brissaud's new modifications; he also got rid of unused v...

...ariables