minor fixes and code improvments