Reorganize Code, add functionalities