Fix for issue 23 & 6

I have added changes that fix #23 & #6 (& possibly #25) as well as a bug where special characters not in a match do not currently get escaped.