Various fixes and improvements from Weebly usage

- Fix nasty index bug on exchange definition retrieval
- Fix some docblocks
- Functionalize connection/channel creation
- Add support for unexpected connection loss