Added comments

Added docstrings and comments to explain the code, also removed an
import of codes which was not used.