core/sched fixup and optimize

* fix some broken misuse of variables (mixing `tcb_t` and `pid_t`)
* fix condition logic (`X && Y != Y` -> `X && (Y != Y)`)
* fix setting and use of `thread_active_pid`, includes optimizations
* refactor `SCHEDSTATISTICS` to make it faster
* remove stale TODO and double spaces
I thought `thread_getlastpid()` was meant as a public interface to an otherwise internal variable. If that is not the case NSS could just as well read the variable directly.