Support for bitmap line styles

Plus some code cleanup and smaller fixes.