Refactored anonymous functions out of trigger registering.