Fix numerical instability in local basis