solved a number of bugs