Merged James' branch. seems ok