Some small code improvs