general tidy up and snippet improvement