fixed a buncha bugs