Misc tweaks and bugfixes.
Convienient wrapper for nnsearch.