Updated comments and complexity.