Fix rand imports and some long lines