use const refs as function parameters
corrected and simplified replacement logic
re-added constructor with initialized macro hash