Cleaned up the main recursive AST function and fixed case statements