Fixed misc bugs.