Normalize variable usage, add further checks