Rename some function and clean up