Some improvements to jQuery for modals