Code review

Don't merge! This review is currently ongoing. I'll add commits and comments individually.