Got generalized sparse ba working, need to clean code and do full test