moved random to its own implementation and header files