spec fixes and some other bugs uncovered by specs