code clearing & optimization