Encapsulated platform dependent code [ci skip]
though it should work, it is untested as I am failing to build currently