multithreading & EntityManagement refactoring