manage fragment visibility, fix bugs