Minor changes preparing for multithreading