[#49] code clean up & add inline comments