r5000

Includes some additional edits of r5000.