Major refactoring to use a 2 D array instead of hash as underlying datastructure.