Bunch of API cleanup;  fixed some issues with tests