Code refactor and Wine support improvements