Improve handling of undefined weights