Fixed issues with CSV file import and code cleanup