rm deadcode and reorganize a bit