added common methods in Commons, minor refactoring