Some code refinement