Final version by Damian.