some cleanup/optimization