various code improvments