Fixes for Safari 8

This whole thing could do with a rewrite :D
v1.0.3