Internal refactoring for speed enhancement.