Cleanup and new basic functions