[refactor] Cleaning up code to put it all together.