Several semantic fixes