Add send timeout functionality, several bug fixes and new unit tests.