I was able to reproduce the mod bias issue with your script. Looking through the code, it appears to be due to a mod/pow combination that over-truncated the resulting value, losing significant bits. I have changed the mod/pow call and it now seems to distribute correctly, including when using 0.66 instead of 0.996. That said, this will need further tests as it is difficult to predict the side-effects of changes like this.
In addition to this change, I have also added $rands() which returns a cryptographically secure random value using Microsoft's SystemFunction036() API.