Fixed everything!

Added sorting algorithm and removed debug lines.