added support for JSON emitting and callbacks