Implemented a very simple lock mechanism to improve support for concurrent executions and prevent failing on Jenkins
Fixed a problem that caused the code to throw a ConcurrentModificationException