support nested macros; clean some code;