changed to double except the headers and rand funcs