@andrey @verdoes
Copy-pasting the lstlisting environments from the PDF (yellow shaded) seems to add spaces where you don't want them. This seems to fix that.