Fixed route functions to be thread-safe