fixing some bugs, simplifying other parts of the code
6 files changed