Merged Adrian/Brendan/Hugh code