Major cleanup of makefiles, api tests.