Major refactor that was long overdue