Perf and cleanup

@jbdeboer I would appreciate if you can review this.

I'm not sure if all the perf changes are ok.

Regarding the style changes, feel free not to merge them or to indicate if some things should be reverted.

Maybe it's better to wait for your "bind-*" to be merged and rebased this PR.