Refactored code so that cell selection code is more modular.
Fixed issue whereby singleton object state would pollute results from multiple runs.