Added stress test and some refactoring.