Pull changes from upstream Datagram (Astron/Astron), add more comments/documentation, cleanup and improve API.