Linux support and refactor