build: Massive overhaul and refactor of code