refactor BFG. Seems like fixed #83 and fixed #53