reorganized a lot
using SafeInt.hpp for both windows and POSIX