Updated with Nicola's patch