Major Fixes

Fixed race conditions in several locations, added thread safety docs,
added exceptions, removed generic thread-safe container in favor of an
internal class, simplified session management.