fix kernel loop, minor changes