Fixes several little bugs.