Removed direct use of $this in anonymous function and closure since it is only supported as of PHP 5.4.0