refactored into more sensible packages