fixed misc bugs