minor design flaws refactored