refactoring some shit, trying to add tests, and making things better hopefully