Split stat funcs and SGD into separate files