Implemented type checking in foreach statements.