Fix macro system bugs