Fix the bugs appeared after last PR

Again, mixing code formatting commits with code changes commits (below...). Bad practice.