added a few bug fixes