Change some relevant methods to synchronized, and add some
documentation.