several border line fixes, and speed optimization for BSON process