Minimizing in-memory string operations, adding 404 for invalid URLs