General cleanup and fixes.