Fixed some semantics issues