Refactor A LOT of code