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
As the name suggests it is used in `core/thread.c`: `int thread_getlastpid(void)` relies on it.