Revert "Fixed a couple of bugs. It's working now."

This reverts commit a72501d7f6bd4e7aafb1e18848faf450d21f480c.
Revert "Revert "Fixed a couple of bugs. It's working now.""

This reverts commit acfd2dfd133444d53c20035a277a8401ffcae09e.