Adding some debug code for solving proc issues

There is some strage concurrecy issue related to updating
current_process_id. This commit adds some debug information when it
happens and triggers kernel panic in case of error. It seems that
current process id is some times incorrect for a short period of time
and if syscall is made during that time the kernel will halt now.

Known issues:
- Still some random kernel panics but the root cause seems to be in proc
  not in anything related to memory management
Minor optimizitasions and refactoring