Adding unit tests, tracking down niggly issues.