Bug fixes and tweaks on top of 0.4.0