Fixed several bugs, PHP notices, and cleaned up a few files.