fixed some bg related bugs