fixed bugs, introduced some