Adding error checking

looking at the formatting of packets to validate them, and updating
globals.h