Revert "Deleted useless code."

This reverts commit a9477126980b7d65c44eca05a5083b06d7be074b.
Bug fixes and comment updates