Adding some comments and efficiency tweaks