fix some obvious bottlenecks