Clean-up and enhancements to indent/dedent and some fixes.

This is a punch of changes I've done when pep8ifying [shinken](/naparuba/shinken) (see this [pull-request](naparuba/shinken/pull/430)), but never created a pull-request for.

I rebased the changes on current master.