Some code improvementes