Fix #70

Fix #70 and small refactoring around that code