Fixed a whole lot of syntax errors and behavior.