Added debugging statements, fixed issue with scripts that don't define a given enter/leave function