Started to fix issue #212

Not mergeable yet, missing tests.