Fixing errors in custom routes containing queries.