Merge bagOfns.py from cfelsgi