removes unnecssary blocks and context entries