Tested extensively, no known bugs. Commented out debugging lines.