Refactored into better packages