Hopefully cleaned up evaluate and is_constant.