Refine codes