Mostly working now, very slightly less ugly