Added test cases.
Bug fixes.
Code Refactoring.