Variety of changes (scoping, indenting, iteration, consistency)

I hope it meets the requirements. If this is accepted, I will continue implementing changes. For detailed log of current changes, refer to the commit log and the actual code diff. This does not introduce any breaking changes.