API cleanup and bugfixes