There's still probably stuff broken, but this seemed like a good spot to commit. Sorry for the enormous chunk of code. I was attempting to update the views, but found that I needed to update a few things elsewhere as well to make them work.