Merged Linux & Windows versions, removing duplicate code