Do some code refinement