Add infinite scroll feature and some code refactoring.