Fixed thread self-halting (its context now is saved properly). Added a memory pool interface (will use it in mutex implementation).