Moved random code out of defines.*