Cleans up the code, adds documentation, adds minor optimizations, adds confetti test.