Bunch of fixes

Does that resolve #412?