fixed the class version and added templated struct. classes are 40% slower for some reason...