fixes and speed ups