clear layers properly

attempt to fix #6