fix misc bugs