Mostly just re-organized stuff, changed a few comments.