Add random function.
Changes from windows
Fix merge issues