fixing some bugs, factoring out a few more views