Memory leak and java 8 issue fix

Hi,

(for ma-ku:master from stroucki:master)
You may be interested in these diffs.

Greetings,
Michael.