More code cleanup and almost done with basic sparsenet fitting function.