Implement 'threshold' arg, fix Python 2 support