Fixed language detection and redirects. Closes #35

Squashed and rebased.