Feature/fix duplicate characters

Replaces #144.