Tidy up imports
Replace STATUS map with status constants
Properly handle headers
Don't send invalid ping message