Added comments. Fixed events registered too soon.