A few attempts at performance improvements

Signed-off-by: Stephen Elford <steve@trafficwebsites.co.uk>