adjust some parameters, tidy up code