refactored to split different loss function types, and clean up some unused functions including wrt. gradients are now taken wrt all parameters always. Basis object also now take a loss and gradient list that decides what will be compiled