Adding pub/sub example and fixed several other issues.
Also improved the logging.