Event handler improvements (cont.)

Swap sorting of hook array from event processing to trigger registration for efficiency.
Plus more PHP 5 updates.