Cleanup

a couple of embarrassing bugfixes, yay for late-night hacking!