Merge pull request #132 from ke-yu/StableBranchWithTestcases

Fix MAGN-865; Code clean up
More clean up in AST nodes to code; fix regressions