Fix apparent bugs