refactoring
main
Delete dead code and remove named return arguments to avoid confusion between them and the returned values. Add documentation.