fix bugs found while reviewing jsfiddle examples