Refactoring and development of #6.