Some small reconnecting client fixes.

- added an optional initial connection delay
- fix issue in gen_server termination
- add possibility so started gen_server can register itself.
upgrade json libs, and fix reconnecting