major breaking up of semantic analyzer to stage for refactoring