Fix various Stem tutorial issues

Some of the Stem tutorials have issues with Python 3 or are using undefined variables. The attached patches fix these issues.