Fixed some issues by scruitinizer