Cleanup, a few bug fixes