Refactoring old POSIX library
Atomic operations and modularized code