more trimming of unneeded things, 380 loc