Don't use deprecated functions on Qt 5.2+
Improve code layout slightly