Fixed thread safety issue in the resource handler.