A little cleanup and some fixes