Restored the extra calls to lock.release().
Without these extra calls you get unexpected behaviour when multiple threads are loaded into the thread pool.
Plus other small updates.
Attribute thread_pool_size of class PrepareAnalysis allows you to set the number of worker threads for an analysis