Major update!
All but replace() function are working properly. I splitted the code. Now it's clear. Currently working on IPC implementation and SIGINT, SIGTERM handling (closing all processes without leaving scraps). It might be still unstable...