Change how function hooks are created (to support future modularization).
Add checking of entity index to player check.