Fixed some issues fiund in code review