Merge pull request #1843 from martinbudden/bf_minor_optimisations