#1537: Fix poor performance