First pass at everything. Lots more needs to be fixed and moved around into the right places, but it's a start.