Cleanup and improved authentication