Refactored Md5Core to remove repetition

Refactored Md5Core to remove repetition