Fixed some problems found on semantic analysis