merged changes from Damien Hardy