added regex support, minor cleanup