fixing logical bugs, minor data structure changes