Code-cleanup/refactoring in built-in implementations. Also gives better (and more consistent) error messages.