Bug fixes, JS improvements