Moving common functionality into libkern