made a few bug fixes