Make 0/1 indexing conversions inplace/efficient
Optimization and replacement of calcLinearState with my 5x faster function