Now correctly (?) handles global vars and consts. Improved test case generation.