Removed unused functions and cleaned the code