Style and speedup and dshape=None fixes

most of the speedup was gained by making these module scope