Some code improvments