Refactoring: increased robustness of some parts of the code.

Nullpointer validations
Synchronized access to some methods
Thread-save datastructure in WorkerStorage