clean up and check of semantics