improve sql, js, docs, other tweaks