Clean-up and enhancements to indent/dedent.

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. Please test with Python 3.x.