Moved some utility functions into views, more cleanup