Remove unused functions and reorganize for readability