Refactor into proper packages