Fully replaced ugly macros with beautiful templates