macro cleanup; from Kaspars Bankovskis, tweaked a bit