properly clean up layers when data path is changed