fixed a few bugs and eliminated some algorithms