Added wave mode and fixed a bug or two