Fixing performance issues with assertions