Fixed problem where swap could not be threadsafe. Improved documentation.