Added lowercase mac os x switch statment, added null checks for HOME variable, added conversion of ~ in paths to HOME variable