some nasty bugs fixed
bug fixes