a couple of bugs fixed