Fix bug #127

I have to add a hack because the code here is not very clear (thanks to @rsanchezbalo for his help).