Generally, here it would be useful to have high-level comments about what each block of code is doing.