Refactor code for easy reuse.

Also change behavior: Now notification are serialized.
It also works when interface is rotated.