Fix document encoding and some style rewrite
Test rewrite
Removed the timeout for re-registering events