Various fixes and enhancements. Thanks Douglas, Nicolas, Ben, Ken and Levente.