remove PIL, rework threading