Changed value type for index, fixes everything. Added comments with attribution.