Fix error reporting.

Fix bug in sweeping.

Allow clients to emit messages themselves.