fixing some bugs after rebase