Move some code into entropic lib