Fix various bugs, add some nice-to-haves.