Bug fixes

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