big cleanup and fix most errors caused by API changes