Remove excess whitespace and use more std algorithms

A few tiny refactorings and removing some excess whitespace.