fix some bugs, grep support