Speedups and a few bugfixes

* Added a settings module to let users/code customize
   the speed/accuracy tradeoff

 * Vectorized a few loops

 * Cache some hotspots

 * Fixed an interpolation bug