Updated random factor generator. WIP, needs tests