pattern fill fixes and optimization