Matt annotated Mike's code, moved to Python 3