takes care of bitmap memory issues (partially), see comments in #60