modified collapse2() to improve speed
modified collapse2() to improve speed
added in collapse3() to give comparison with collapse2(), added performance benchmarks
PEP8 changes