lots of fixes for things like #3 and #4