Cleanup sources and fix to dart 17463

Signed-off-by: Daniel Thomas <drt24@cam.ac.uk>