Fixed a variety of semantic issues