Critical sections added+GUI freezes & interblocking

Not funny anymore.

GUI freezes and interblocking appeared with the critical sections.