Did some refactoring to make cluster code simpler.