rename some variables for clarity
fix missing imports