Code clean up.

Events moved to NG level.
Bug fixes and code clean ups.