Add target logic, fix rpm bug