Fix previous broken commit. Still have same unsatisfactory performance it turns out.