Fixed Issues found by code analysis