Minor speed enhancements

Fix minor bottlenecks identified by the shiny new gprof integration