Merge pull request #2392 from MartinNowak/fix13232

Issue 13232 - avoid expensive template instantiations on module import
Merge pull request #2374 from Dicebot/nan-deprecation

[reg] isNaN deprecation for integers
Merge pull request #2404 from AndrewEdwards/2.066

Cherry-picking commits from master to 2.066 branch (for RC2)