Fix some misc bugs