Completely rewrote the codebase