Refactoring, and added Pair class to common module