use lodash instead of jquery debounce
fix several embarrasing bugs