fixes #1768 and #1777
Merge pull request #1819 from state-hiu/ngcloak

ngCloak fixes