Reorganize platform independent functions into a single script