Fixed some cross-browser compatibility issues, made it slightly less ugly