Tidy up; incorporate upstream #18