Added a few comments and increase some code readability.