Improve Router performance and error handling