fixed bugs in views and some model based functions used by views