Fixed several small bugs.