Change type from double to ulong where it makes sense