Properly parse region ends, closes #337