rather large cleanup