Avoid eval
More precise handling of tree weight expressions