Nested stuff up in here. Still messy. I wish I could write strongly-typed SQL.