Fixed major bugs