Fix preferences in Qt. Add a lot of comments. Close 1305