Added ping messages.  General tidying up.