Added some formal documentation, removed trivial lines of codes, and fixed some lines of codes for readability.