fixed buncha bugs