fixed some but not all bugs