Fix misc bugs.