Rename functions and cleanup