fixed some major bugs