Unofficial Python 3 port of slimmer.py