bug fix + cleanup