Replace htonl with bigendian macro

This way we don't need to include arpa/inet.h or winsock2.h.
Remove unused variable
Fix misplaced constants