Added sorting by name, fixed errors