added intelligent handling of bitmaps, also added comments for
uncommented code.