Cleanup and porting to QML.