Pulled changes from bonifaido fork for pub/sub implementation.