Add some comments and remove unused functions