Fix mixed up input and output variables. Add a couple of missing packages.