Restructured code to allow for semantic analysis, other intermediate steps