extracted gamestateisnull.  removed printerror.  extracted Patterns.