added couple of bug fixes