do not remove intermediates to reduce warning; fix potential thread-safe issue