Fixes for IE7/8 pointed out by @JamesMGreene