In progress fixes for #777 - dont depend ot Qt and QGIS libs in safe package. Plus code formatting cleaups.