Refactor into appropriate packages