Please do not merge. This is old version for some reason. Did a few fixes.