Made the cardindex configurable, which is necesary in some scenarios.
Also made the code pep-8 compliant.