Refactoring

Please review and discuss.