replaced preg_replace with str_replace where able.