Check buffer boundaries (ok, the lazy way) when building a regexp.
Add comments
Add check for dirname()