Add heartbeat function to send out heartbeat packets.
Security error messages in some functions