optimised indent and changes to foreach

indent is now ~ 3x faster when tested on real code.

using foreach is neater/more D-idiomatic.