Migrate some fetch queries to prepared statements, fix typo in the caching regex