Merged of kk-dev and fixes to make it compile