Made javascript functions generic; Minor under-the-hood layout tweaks