Added a bit of doc plus some locks, had to comment out the locks though, wouldn't compile on this platform