Fix clearing bugs