Lock improvements

Trying to clean up locking in licode to reduce deadlocks and make threading better.  So far, it's been good.