Fixing some misc bugs