Refactoring towards RFC 6901 - closes #2