fix safari issues; advanced optimizations