NXBT-758: refactoring and improvements

Add logging, commands and options
Improve the algorithms (especially with caching and refactored loops)
NXBT-758: CSV export; better merge strategy
NXBT-758: CSV import