refactor: basically everything, also tests