Added some checks for functions that aren't available on older browsers.