This code come from Enesim and was done by Jorge. I did just take care of changing the namespace and coding style.