Fix https://github.com/ContinuumIO/bokeh/issues/675
fix https://github.com/ContinuumIO/bokeh/issues/466