Reported, analised and fixed by Tiago Quintela and Nuno Mota. Signed-off-by: Pedro Melo <melo@simplicidade.org>