Refactor

Hey, there's still some work to do but here's my contribution.