Fixed getNearestPowerOfTwo returning one less than it was supposed to.