Refactored the core algo and adapted double-1/double-20 DSA rule.