lots of cleanup, fixed a few bugs
new scheme