minor bug fixes and code reorganization

ok they aren't really bugs, but they're minor features that I thought
were there before, but weren't