Ported from Poppy's PBO w/ his changes