fixed bugs that resulted from bad merge.