Optimizations

Loose collection of commits adding tests, profiling and some minor code cleanups, mainly made while I got familiar with the code base (still digesting the paper). Best to view individually. Happy to create individual pull requests if preferred.