Added explanation comments on hard-to-understand parts