Fix minor semantic bugs