Merge from levels.

I think I got everything working right again, with Ryan's changes added.
Haven't done anymore than merging them though so something's may need
changing slightly.