Various small bug fixes. Works now