WIP: refactor lots of shit