refactored reading header and payload
turned on all compiler warnings