Fixed locking issues and exceptions in real-time data. Fixed bug in xsockets.
Improved code organisation