Cleanup and bugfixes of backend scripts