API changes, cleanup, test improvements