complete refactoring; temporary for testing/tweaking and then will split into multiple packages