Finish all functions and clear up codes.