Added more comments and removed some code