Code refactoring

see #210