cleanup and fixing quantity arrays