Modified according to comment by italorossi on #8