cleaner cmd expansion, renamed some vars, removal of temp files
fixed syntax err