Rebased to Master and fixed up