support Darwin and do tiny cosmetic refactoring