E.g. reducing deep indention and code duplication. Removing comments
that literally repeat what the code says.
The goal is to make the code easier to read and to maintain in the
future. I hope this is the case.
Change-Id: I6f23bc61ffb8b6d42ec697fec91bb6c92152561f