Remove trailing whitespace. My editor is setup to remove it automatically. ;-)

I am doing this first, so that the next checkin with the real changes
will be clean.
Fix demo page.
Remove trailing whitespace.
Implemented ability to emit change events.

The feature is controlled through the new "emitEvents" setting. To keep
backward-compatibility I turned event emission off by default.