Refactoring (and fix #1)