Performance

Resubmitting the fix for #114 from a separate performance branch on my repo.