More changes. fixed some bugs ; error testing