Minor JS improvements to prevent JS errors

Signed-off-by: Elliot Condon <e@elliotcondon.com>