New fixes and features

Should fixes coverity defects