Added a few bug fixes to sync up to repo.