Fixed crashes from recycled bitmaps by creating real copies of bitmaps if necessary + some minor refactoring