Finished the main functionalities.