Totally fixed
Some work on escape.c
Added sharedtools.h, which contains useful bits.