cleanup+optimization+stuff