cleaning up views, changed some database code