backported changes from kans/zirgo