Major rework with async

Did a massive rework to make the library work with async and await so
the calls are no longer all fully blocking. Also added a new type of
message that can wait for a response to be sent.
Improved the locking code

Improved the locking code to lock less and to lock separately for stuff
related to sending data and stuff related to recieving data since the
locks needed for those are completely unrelated.
Bug fixes

Some bug fixes to actually make the library work correctly.