Fixed warnings and put ifs into blocks.