Fix category discussion counter

Ensure that discussion counter increments when a discussion is moved to a new category. Convert tabs to spaces and add braces to all control statements.