Some fixes, refactoring and csv downloader