Fixes more issues regarding popping of states in for/while.
Adds support for global constants (registered externally).