Added bugfixes for spark distribution according to blogpost