Working on unit tests. Various minor tweaks