Some code refinations