Merge "Some refactoring for fixing the tests and also eliminating the use of TreeMap but use a more light weight data structure."