Fix a bug in custom directive implementation, where a custom directive placed into a dir container was causing a global perl context change which was leading to a segfault in any handler called thereafter.