some refactoirng an cleanup/fixes when runnint on a Mac