Bunch of refactoring and stuff. Not too sure what's already upstream.

This patch builds. I've implemented project discussion pages and perhaps some other stuff that's not yet upstream. I think it's time to get this merged over, pushed live, and then we can start squashing bugs that I've no doubt introduced.