Fixed some bugs on Windows
More work on preferences dialog