Fixed sys.exit(). Added docstrings