fixed a few bugs, commented