Cleanup and  renaming, also improved tests