HRCPP-27 Correctly initialize protocol version

- Also make CodecFactory a proper singleton so that dynamically allocated codecs are freed on exit
- Use a signed int to calculate the number of transports
- Now the valgrind tests pass