Fixed about a thousand notices and bugs. (Maybe even more).