Fixed warning and bug