Script improvements; tidyups