Ported recent refactoring of BLZ to Python 3