Update OS API wrapper

* Add sigprocmask
* Miscellaneous fixes and refactoring