Fixed insane memory exhausting issue.
Increased performance by using an assoc array.